<?php

namespace App\Jobs;

use Carbon\Carbon;
use App\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use App\Services\CloseUnpaidProductOrder\CloseUnpaidProductOrder;

class CloseOrderJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    
    protected $order;
    
    public function __construct(Order $order)
    {
    	$this->order = $order;
    	$this->delay(Carbon::now()->addMinutes(10));
    }
	
	public function handle()
    {
        app(CloseUnpaidProductOrder::class, [
        	'order' => $this->order
        ])->closeByJob();
    }
}
